const { indexForm39 } = require("./indexForm39");
const { ListMy } = require("./ListMy");

const serverMap = {
  // 团购列表查询
  "/index.asp": indexForm39,
  "/List_my.asp": ListMy,
  "/GetRole.asp": ({ res, response }) => {
    const notLogin = response.includes("请先登录");
    if (notLogin) {
      return JSON.stringify({
        code: "403",
        message: "请先登录",
        success: true,
      });
    }
    res.status(200);
    return JSON.stringify({
      success: true,
    });
  },
  "/inc/Buy.Check.asp": ({ res, response }) => {
    console.log(response);
    const isBuy = response.includes("购买成功");
    if (!isBuy) {
      return JSON.stringify({
        success: false,
      });
    }

    return JSON.stringify({
      success: true,
    });
  },
  "/buy.asp": ({ res, response }) => {
    console.log(response);
    const Sign = response.match(/Sign=(.*?)"/)?.[1];

    const Timestamp = response.match(/Timestamp=(.*?)&/)?.[1];

    return JSON.stringify({
      success: true,
      data: { Sign, Timestamp },
    });
  },
};

module.exports = {
  serverMap,
};
